{% extends 'base.html' %}
{% load blog_tags %}

{% block title %}
    My blog
{% endblock %}

{% block content %}
    <h1>My Blog</h1>
    {% if tag %}
        <h2>Posts tagged with "{{ tag.name }}"</h2>
    {% endif %}
    {% for post in posts %}
        <h2>
            <a href="{{ post.get_absolute_url }}">
                {{ post.title }}
            </a>
        </h2>

        <p class="tag">
         Tags:
            {% for tag in post.tags.all %}
                <a href="{% url 'post_list_by_tag' tag.slug %}">{{ tag.name }}</a>
                {% if not forloop.last %},{% endif %}
            {% endfor %}
        </p>

        <p class="date">
            Published {{ post.publish }} by {{ post.author }}
        </p>
        {{ post.body |markdown | truncatechars_html:30 }}
    {% endfor %}
    {% include 'pagination.html' with page=posts %}
    {#    {% include 'pagination.html' with page=page_obj %}#}
{% endblock %}